// 字符串字面量
let specifiedStr: 'this is string' = 'this is string'
let specifiedNum: 1 = 1
let specifiedBoolean: true = true

// 字面量类型与子类型的区别,相当于父类与子类的区别
let str: string = 'any string'
str = specifiedStr
// specifiedStr = str // error 不能将类型“string”分配给类型“"this is string"”

// 应用场景-字面量联合类型
type Direction = 'up' | 'down'
function move(dir: Direction) {
    console.log(dir)
}
move('up')
// move('left') // 类型“"left"”的参数不能赋给类型“Direction”的参数

// 数字字面量类型及布尔字面量类型
interface Config {
    size: 'small' | 'big';
    isEnable:  true | false;
    margin: 0 | 2 | 4;
}

// let 和 const 分析
{
    const str = 'this is string' // str: "this is string"
}
{
    let str = 'this is string' // str: string
}